#include "InputManager.h"
#include <string.h>
#include "include/ILog.h"

CInputManager::CInputManager()
{
	memset((void*)KeyStates,0,KEY_CODES_COUNT*sizeof(SKeyInput));
	Proccess = false;
	pLogRelease << "InputManager crated..." << endl;
}

CInputManager::~CInputManager()
{
}

void CInputManager::NewKey(SKeyInput *NewKI)
{
	SKeyInput *ActualKey = &(KeyStates[NewKI->Key]);
	ActualKey->Char = NewKI->Char;
	ActualKey->Control = NewKI->Control;
	ActualKey->Shift = NewKI->Shift;
	ActualKey->PressedDown = NewKI->PressedDown;
	ActualKey->Pushed = ActualKey->PressedDown;
	ActualKey->Released = !(ActualKey->PressedDown);
	Proccess = true;
}

void CInputManager::UpdateKeys()
{
	if (Proccess)
	{
		for (u32 i=0;i<KEY_CODES_COUNT;i++)
		{
			KeyStates[i].Pushed = false;
			KeyStates[i].Released = false;
		}
		Proccess = false;
	}
}

SMouseState *CInputManager::GetMouseState()
{
	return &MouseState;
}

void CInputManager::SetMouseState(SMouseState *other)
{
	MouseState.LeftButtonPressed = other->LeftButtonPressed;
	MouseState.MidleButtonPressed = other->MidleButtonPressed;
	MouseState.RightButtonPressed = other->RightButtonPressed;
	MouseState.Pos = other->Pos;
	MouseState.PosDif = other->PosDif;
}
